import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: () => import('@/views/index.vue'),
    children: [
      {
        path: '',
        component: () => import('@/views/index/index.vue'),
      },
      {
        path: 'cloudSpace',
        component: () => import('@/views/index/cloudSpace.vue'),
        children: [
          {
            path: 'detail/:type',
            component: () => import('@/views/index/cloudSpace/detail.vue'),
          },
          {
            path: 'recycleBin',
            component: () => import('@/views/index/cloudSpace/recycleBin.vue'),
          },
          {
            path: 'shareFiles',
            component: () => import('@/views/index/cloudSpace/shareFiles.vue'),
          },
        ]
      },
      {
        path: 'dynamic',
        component: () => import('@/views/index/dynamic.vue'),
        children: [
          {
            path: 'uploadList',
            component: () => import('@/views/index/dynamic/uploadList.vue'),
          },
          {
            path: 'overList',
            component: () => import('@/views/index/dynamic/overList.vue'),
          },
          {
            path: 'downloadList',
            component: () => import('@/views/index/dynamic/downloadList.vue'),
          },
        ]

      },
      {
        path: 'group',
        component: () => import('@/views/index/group.vue'),
      },
      {
        path: 'setting',
        component: () => import('@/views/index/setting.vue'),
        children: [
          {
            path: 'resetPassword',
            component: () => import('@/views/index/setting/resetPassword.vue'),
          },
          {
            path: 'login',
            component: () => import('@/views/index/setting/login.vue'),
          },
        ]
      }
    ]
  },
  {
    path: `/share`,
    component: () => import('@/views/share.vue'),
    children: [
      {
        path: ':code',
        components: {
          pc: () => import('@/views/share/pcShare.vue'),
          phone: () => import('@/views/share/phoneShare.vue')
        },
      },
    ]
  },
  {
    path: `/invite`,
    component: () => import('@/views/invite.vue'),
    children: [
      {
        path: ':code',
        components: {
          pc: () => import('@/views/invite/pcInvite.vue'),
          phone: () => import('@/views/invite/phoneIncite.vue')
        },
      },
    ]
  },
  {
    path: '/shareSet',
    component: () => import('@/views/share/set.vue'),
    redirect: 'shareSet/login',
    children: [
      {
        path: '/shareSet/login',
        component: () => import('@/views/share/set/login.vue'),
      },
      {
        path: '/shareSet/register',
        component: () => import('@/views/share/set/register.vue'),
      },
      {
        path: 'perfectInformation',
          component: () => import('@/views/share/set/perfectInformation.vue'),
      },
      {
        path: '/shareSet/retrievePassword',
        component: () => import('@/views/share/set/retrievePassword.vue'),
      },
      {
        path: 'setPassword',
          component: () => import('@/views/share/set/setPassword.vue'),
      },
    ]
  },
  {
    path: '*',
    redirect: '/'
  }

]

const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
